package org.example.demosr4.dao;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.example.demoone.entity.Student;

import javax.smartcardio.Card;
import java.util.List;

@Mapper
public interface StudentMapper {
    @Result(property = "card",column = "number",one=@One(select="org.example.demosr4.dao.StudentMapper.getCardByNumber" ))
    @Select("select * from student where number like concat('%',#(name),'%')")
    Card getCardByNumber(String number);

    @Select("select * from card where number=#{number}")
    Card getCardByNUmber(String number);

    @Select({
            "<script>",
            "select * from student where 1=1",
            "<if test='name !=null'>",
            "and name=#{name}",
            "</if>",
            "<if test='number!=null'>",
            "and number=#{number}",
            "</if>",
            "</script>"
    })
//    List<Student> getStudentByName(String name, String number);
    List<Student> getStudentByNameOrNo(String name, String number);

}
